package com.elink.enginerring.news;

import io.swagger.annotations.Api;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.elink.enginerring.common.BaseCo;
import com.elink.enginerring.datasource.DataSourceContextHolder;
import com.elink.enginerring.datasource.DataSourceType;
import com.elink.enginerring.news.service.INewsCommentService;


@RestController
@RequestMapping("/news/comment")
@Api(value="新闻资讯的评论")
public class NewsCommentController {
	@Autowired
	private INewsCommentService newsCommentService;

	/**
	 * 分页获取列表
	 * @param bc
	 * @param type 0--未审核 1--已经审核 
	 * @return
	 */
	@RequestMapping(value = "/getList", method = RequestMethod.GET)
	public Map<String, Object> getList(
			@ModelAttribute @Valid BaseCo bc,
			@RequestParam("type")String type) {
		DataSourceContextHolder.setDbType(DataSourceType.DBNEWS);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType());
		return newsCommentService.getListOfPage(bc,type);
	}
	
	/**
	 * 审核评论
	 * @param ids
	 * @return
	 */
	@RequestMapping(value="addAuth",method=RequestMethod.GET)
	public Map<String, Object>addAuth(@RequestParam("ids")String ids){
		DataSourceContextHolder.setDbType(DataSourceType.DBNEWS);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType());
		return newsCommentService.addAuth(ids);
	}
}
